package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.CldWelfareSendDetails;
import com.cleaningcloud.cld.domain.dto.CldWelfareSendDto;
import com.cleaningcloud.cld.domain.vo.CldWelfareSendDetailsVo;
import com.cleaningcloud.cld.domain.vo.CldWelfareSendVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.service.ICldWelfareSendService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 福利管理Controller
 * 
 * @author cleaningcloud
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/CldWelfareSend")
public class CldWelfareSendController extends BaseController
{
    @Autowired
    private ICldWelfareSendService cldWelfareSendService;

    /**
     * 查询福利管理列表
     */
    @RequiresPermissions("cld:CldWelfareSend:list")
    @GetMapping("/list")
    public TableDataInfo list(CldWelfareSendDto cldWelfareSend)
    {
        startPage();
        List<CldWelfareSendVo> list = cldWelfareSendService.selectCldWelfareSendList(cldWelfareSend);
        return getDataTable(list);
    }

    /**
     * 获取福利管理详细信息
     */
    @RequiresPermissions("cld:CldWelfareSend:query")
    @GetMapping(value = "/{welfareSendId}")
    public AjaxResult getInfo(@PathVariable("welfareSendId") Long welfareSendId)
    {
        return success(cldWelfareSendService.selectCldWelfareSendByWelfareSendId(welfareSendId));
    }

    /**
     * 查询福利发放明细列表
     */
    @RequiresPermissions("cld:CldWelfareSend:query")
    @GetMapping("/detailsList")
    public AjaxResult list(CldWelfareSendDetails cldWelfareSendDetails)
    {
        List<CldWelfareSendDetailsVo> list = cldWelfareSendService.selectCldWelfareSendDetailsList(cldWelfareSendDetails);
        return success(list);
    }

    /**
     * 新增福利管理
     */
    @RequiresPermissions("cld:CldWelfareSend:add")
    @Log(title = "福利管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldWelfareSendDto cldWelfareSend)
    {
        return toAjax(cldWelfareSendService.insertCldWelfareSend(cldWelfareSend));
    }

    /**
     * 修改福利管理
     */
    @RequiresPermissions("cld:CldWelfareSend:edit")
    @Log(title = "福利管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldWelfareSendDto cldWelfareSend)
    {
        return toAjax(cldWelfareSendService.updateCldWelfareSend(cldWelfareSend));
    }

    /**
     * 修改福利管理
     */
    @RequiresPermissions("cld:CldWelfareSend:edit")
    @Log(title = "福利管理", businessType = BusinessType.UPDATE)
    @PutMapping("/updateDetails")
    public AjaxResult updateDetails(@RequestBody CldWelfareSendDetails cldWelfareSendDetails)
    {
        return toAjax(cldWelfareSendService.updateCldWelfareSendDetails(cldWelfareSendDetails));
    }

    /**
     * 删除福利管理
     */
    @RequiresPermissions("cld:CldWelfareSend:remove")
    @Log(title = "福利管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{welfareSendIds}")
    public AjaxResult remove(@PathVariable Long[] welfareSendIds)
    {
        return toAjax(cldWelfareSendService.deleteCldWelfareSendByWelfareSendIds(welfareSendIds));
    }
}
